.PHONY: docker
docker:
	@rm -rf webook
	@go mod tidy
	@GOOS=linux GOARCH=arm go build -tags=k8s -o webook .
	@docker rmi -f test/webook:v0.0.1
	@docker build -t test/webook:v0.0.1 .

.PHONY: mock
mock:
	@mockgen -source=./internal/service/user.go -package=mocks -destination=./internal/service/mocks/user.mock.go
	@mockgen -source=./internal/service/article.go -package=mocks -destination=./internal/service/mocks/article.mock.go
	@mockgen -source=./internal/service/code.go -package=mocks -destination=./internal/service/mocks/code.mock.go
	@mockgen -source=./internal/repository/user.go -package=mocks -destination=./internal/repository/mocks/user.mock.go
	@mockgen -source=./internal/repository/code.go -package=mocks -destination=./internal/repository/mocks/code.mock.go
	@mockgen -source=./internal/repository/dao/user.go -package=mocks -destination=./internal/repository/dao/mocks/user.mock.go
	@mockgen -source=./internal/repository/article/article.go -package=artmocks -destination=./internal/repository/article/mocks/article.mock.go
	@mockgen -source=./internal/repository/article/article_author.go -package=artmocks -destination=./internal/repository/article/mocks/article_author.mock.go
	@mockgen -source=./internal/repository/article/article_reader.go -package=artmocks -destination=./internal/repository/article/mocks/article_reader.mock.go
	@mockgen -source=./internal/repository/cache/user.go -package=mocks -destination=./internal/repository/cache/mocks/user.mock.go
	@mockgen -source=./internal/repository/cache/code.go -package=mocks -destination=./internal/repository/cache/mocks/code.mock.go
	@mockgen -source=./internal/service/sms/types.go -package=mocks -destination=./internal/service/sms/mocks/types.mock.go
# 对于第三方接口的mock参考↓，不需要source，因为不是mock本地的某个文件，取而代之的是在后面加上仓库名和接口名，可以同时mock多个接口，使用逗号进行分隔，比如我mock Cmdable和hello，最后就改为Cmdable,hello 注意中间不能有空格，只能有逗号，这样会将mock的两个接口都mock到一个文件中
	@mockgen  -package=redismocks -destination=./internal/repository/cache/redismocks/cmdable.mock.go github.com/redis/go-redis/v9 Cmdable
	@mockgen  -package=mocks -destination=./internal/service/sms/mocks/ratelimiter.mock.go github.com/HJH0924/GenericGo/ratelimiter RateLimiter
	@mockgen  -package=logmocks -destination=./internal/web/article/logmocks/logger.mock.go github.com/HJH0924/GenericGo/logger Logger
	@go mod tidy

.PHONY: bench
bench:
	@go test -bench=. -benchmem ./...
